<!--专家指导所有专家详情界面-->
<template>
    <div class="goods-box4">
        <div class="search">
            <div style="display: flex;height: 35px;line-height: 35px;">
                <el-input v-model="searchKeys" maxlength="100" clearable style="width:290px;" />
                <img src="@/assets/img/search.png" @click="handleSearch" class="search-icon" />
            </div>
            <el-button v-show="searchKeys != ''" style="width: 80px;height:35px;line-height: 35px;margin-left: 10px;"
                @click="backHandle">
                <el-icon>
                    <Close />
                </el-icon>取 消
            </el-button>
        </div>
        <div class="goods" v-for="(item, index) in cexpertArray"
            :style="index === cexpertArray.length - 1 ? '' : 'border-bottom:1px solid #f2f2f2;'" :key="index">
            <img src="@/assets/experts.png" alt="" />
            <div class="info">
                <p class="content">
                    <span style="margin-right:50px;">专家姓名：{{ item.realName }}</span>
                    <span>职称：{{ item.position }}</span>
                </p>
                <p class="content">
                    <span style="margin-right: 50px;">从事专业：{{ item.profession }}</span>
                    <span>联系电话：{{ item.phone }}</span>
                </p>
                <p class="content">
                    <span>单位：{{ item.belong }}</span>
                </p>
            </div>
            <div class="info2">
                <span class="question-btn" @click="handleQuestion(item)" style="margin-right:20px;">向我提问</span>
                <span class="question-btn" @click="handleAppointment(item)">线下预约</span>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref } from 'vue'
import { defineEmits, defineProps } from 'vue';
import store from '@/store'
const emit = defineEmits(['handleSearch', 'refresh']);
import { useRouter } from 'vue-router';
const router = useRouter()
// 接收父组件传过来的数据
const props = defineProps({
    cexpertArray: {
        type: Array,
    }
})

//搜索
const searchKeys = ref('');

//搜索
const handleSearch = () => {
    emit('handleSearch', searchKeys.value)
}

//返回
const backHandle = () => {
    searchKeys.value = ''
    //调用父类的方法
    emit('refresh')
}


const handleQuestion = (item) => {
    if (store.state.token !== null || store.state.token !== '') {
        router.push(`/index/question?id=${item.userName}`).catch((err) => err);
    } else {
        router.push(`/login`).catch((err) => err);
    }
}
const handleAppointment = (item) => {
    if (store.state.token !== null || store.state.token !== '') {
        router.push(`/index/appointment?id=${item.userName}`).catch((err) => err);
    } else {
        router.push(`/login`).catch((err) => err);
    }
}

</script>

<style lang="scss" scoped>
.search {
    height: 60px;
    background-color: white;
    padding: 10px 20px;
    margin-top: 10px;
    align-items: center;
    display: flex;

    .search-icon {
        cursor: pointer;
    }
}

.goods-box4 {
    text-align: left;
    background-color: #fff;
    width: 1100px;
    margin: 0 auto;
    color: rgb(57, 55, 55);

    .goods {
        width: 1100px;
        height: 110px;
        padding: 10px 20px;
        background-color: white;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;

        img {
            width: 100px;
            height: 85px;
            margin-right: 20px;
            border-radius: 6px;
        }

        .info {
            padding: 10px 0;
            width: 800px;
            font-size: 14px;
            height: 100px;
            display: flex;
            /*重要*/
            flex-wrap: wrap;

            .initiator {
                color: #666;
            }

            .title {
                /*超出的部分隐藏*/
                overflow: hidden;
                /*文字用省略号替代超出的部分*/
                text-overflow: ellipsis;
                /*弹性伸缩盒子模型显示*/
                display: -webkit-box;
                /*限制在一个块元素显示文本的行数*/
                -webkit-line-clamp: 1;
                /*设置或检索伸缩盒对象的子元素排列方式*/
                -webkit-box-orient: vertical;
            }

            .content {
                width: 100%;
                height: 20px;
                /*超出的部分隐藏*/
                overflow: hidden;
                /*文字用省略号替代超出的部分*/
                text-overflow: ellipsis;
                /*弹性伸缩盒子模型显示*/
                display: -webkit-box;
                /*限制在一个块元素显示文本的行数*/
                -webkit-line-clamp: 7;
                /*设置或检索伸缩盒对象的子元素排列方式*/
                -webkit-box-orient: vertical;
            }

            .price {
                font-weight: bold;
                display: block;
                color: red;
            }
        }
    }
}

.info2 {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: flex-end;

    .question-btn {
        cursor: pointer;
        color: #67C23A;

        &:hover {
            text-decoration: underline;
            color: #035D1C;
        }
    }
}

.search .el-input--suffix .el-input__inner {
    height: 35px;
    line-height: 35px;
}
</style>